package todolist.test;


import java.util.List;

import todolist.activities.ListScreenActivity;
import todolist.structures.Task;
import android.test.ActivityInstrumentationTestCase2;
import android.widget.TextView;

public class JUnitListScreenActivity extends ActivityInstrumentationTestCase2<ListScreenActivity> {
    private ListScreenActivity mActivity;  // the activity under test
    private TextView mView;          // the activity's TextView (the only view)
    private String resourceString;
    List<Task> tasks;
    
    public JUnitListScreenActivity() {
      super("todolist.activities", ListScreenActivity.class);
    }
    @Override
    protected void setUp() throws Exception {
        super.setUp();
        mActivity = this.getActivity();
    }
    public void testPreconditions() {
      assertNotNull(mActivity);
    }
    
    /*
     * These tests achieve branch coverage for the date filter.
     * a valid date is entered and saved, and then passed into the dateOrder method
     * the values are then compared, and the higher date should come back as larger
     */
	
	public void testDateFilterWrong() {
		
		int date1 = mActivity.dateOrder("04-05-2012");
		int date2 = mActivity.dateOrder("03-05-2012");
		assertFalse("Date Filter Wrong", (date1<date2));

	}

	public void testDateFilterRight() {

		int date1 = mActivity.dateOrder("04-05-2012");
		int date2 = mActivity.dateOrder("03-05-2012");
		assertTrue("Date Filter Right", (date1>date2));

    }
	
	public static boolean checkDate(String date) {
		return date.matches("[0-9]{1,2}[-][0-9]{1;2}[-][0-9]{1,4}");
	}    
}